package com.test.spring.transaction.annoation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/9/29 10:49
 */
@Service("cashier")
public class CashierImpl implements Cashier {

    @Autowired
    private BookShopService bookShopService;

    /**
     * 添加事务处理
     *
     * @param username
     * @param isbns
     */
    @Transactional()
    @Override
    public void checkout(String username, List<String> isbns) {
        isbns.forEach(isbn -> {
            bookShopService.purchase(username, isbn);
        });
    }
}
